// JavaScript Document
function buy_click(foodID,foodImage){
	//alert(foodImage);
	document.getElementById("bucket").src = "images/KFCFULL.png";
	$("#billDiv").load("Bill.aspx?FoodID="+foodID+"&FoodImage="+foodImage);
};

function refresh_bill(){
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
		//	alert("begin 2");
	}
	
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{

			document.getElementById("billDiv").innerHTML = xmlhttp.responseText;
		}
	}
	//	alert("Bill.aspx?RefreshPage=true");	
	xmlhttp.open("GET","Bill.aspx?RefreshPage=true",true);
	xmlhttp.send();
	
	//$("#billDiv").load("Bill.aspx?RefreshPage=true");
};

$(document).ready(function () {
	
	//Test thử js
	/*
	$("a").click(function (e) {
		alert("As you can see, the link no longer took you to to where you want");

	});
	$("header").mouseenter(function (e) {
		$(this).hide("slow");
	});
	$("header").mouseleave(function (e) {
		$(this).show("slow");
	});
	*/
	//END: Test thử		
	
	//Test event
	/*
	$(".product").mouseenter(function(e) {
		$(this).animate({
			opacity: 1
			},"fast");
	});
	$(".product").mouseleave(function(e) {
		$(this).animate({
			opacity: 0.7
			},"fast");
	});
	*/
	//END: Test event
	
	$(".butBuy")
				.bind("click",function() {
					$(this).parent().parent().parent().parent().parent().parent().effect("transfer", { to: $("#bucket") }, 1000
				);
	});
	
	//Bill chay theo page
	$(document).scroll(function(e) {
		var top_last = 0;
		var top_now = $(document).scrollTop();
		var top_st =  top_now - top_last + 50;
		$("#bill").stop(true).animate({
								'top': top_st
								},'fast');
		top_now = top_last;
    });
	
	//Code thiet lap dialoag
	$( "#dialogCheckout" ).dialog({
			autoOpen: false,
			//show: "bounce",
			hide: "explode",
			modal: "true",
            width: "600",
            height: "auto",
			resizable: false,
            close: function (event, ui) { 
                $("#dialogCheckout").dialog({
                    title: "Check out",
	            });
             }
		});
});

function showCheckout() {
	//document.getElementById("checkoutDiv").innerHTML = "";
	
    $("#checkoutDiv").load("CheckOut.aspx");

		$("#btNewUser").click();
		billDivClicked = true;
//		alert("Done click");
		$("#checkoutDiv").load("CheckOut.aspx");

    $("#dialogCheckout").dialog("open");
    return false;
};